package dreampack.tool;

import javax.servlet.http.HttpServletRequest;
import java.util.StringTokenizer;

public class VersionTool {
	/*
	 * 目前暂时只需要控制css文件的版本及浏览器特性，js只需一份
	 */
	public VersionTool() { }
	
	public static String getCurVersion(String key) {
		// key: 即为文件名
		return "1.0";
	}
	public static String getExplorerType(HttpServletRequest req) {
		String agent = req.getHeader("user-agent");
		StringTokenizer st = new StringTokenizer(agent,";");
		st.nextToken();
		String userbrowser = st.nextToken();	//得到用户的浏览器名
		return userbrowser;
		//return "undefined";
	}
	public static String getFNameWithVer(String fileName, HttpServletRequest req, String extName) {
		return fileName + "_" + getExplorerType(req) + "_" + getCurVersion(fileName) + "." + extName;
	}
}
